package rpc

import (
	"errors"
	"fmt"
	"go-monitor/agent/service"
	"go-monitor/common/model"
)

type Client int

// Test test
func (this *Client) Test(req model.NullRPCRequest, resp *model.SimpleRPCResponse) error {
	signorign, err := service.RsaDecrypt([]byte(req.Sign))
	if err != nil {
		resp.Code = 1
		resp.Message = fmt.Sprintf("server auth decrypt err: %s", err)
		return err
	}

	if string(signorign) != model.SignOrign {
		resp.Code = 1
		resp.Message = fmt.Sprintf("server auth check err: %s", "signorign is not right")
		return errors.New("signorign is not right")
	}
	// 监控数据
	fmt.Println("test")

	resp.Code = 0
	resp.Message = "success"
	return nil
}
